import Vue from 'vue'
import Router from 'vue-router'
import i18n from '@/lang'
Vue.use(Router)

import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true,
    meta: {
      title: '登录-滴灯管理平台'
    }
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/dashboard',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '数据概览', icon: 'iconfont icon-zanwushuju' }
    }]
  },


  {
    path: '/addSharedOrders',
    component: Layout,
    children: [{
      path: 'addSharedOrders',
      name: 'addSharedOrders',
      component: () => import('@/views/SharedOrders/orderadmin/add.vue'),
      hidden: true,
      meta: {
        title: '新增共享订单',
        // keepAlive:true,
        icon: 'iconfont icon-zanwushuju'
      }
    }]
  },
  {
    path: '/addProduct',
    component: Layout,
    children: [{
      path: 'addProduct',
      name: 'addProduct',
      component: () => import('@/views/ProductAdmin/xpProduct/add.vue'),
      hidden: true,
      meta: {
        title: '发布新品商品',
        // keepAlive:true,
        icon: 'iconfont icon-zanwushuju'
      }
    }]
  },

  {
    path: '/addGXProduct',
    component: Layout,
    children: [{
      path: 'addGXProduct',
      name: 'addGXProduct',
      component: () => import('@/views/ProductAdmin/gxProduct/add.vue'),
      hidden: true,
      meta: {
        title: '发布共享商品',
        // keepAlive:true,
        icon: 'iconfont icon-zanwushuju'
      }
    }]
  },


  {
    path: '/addpjProduct',
    component: Layout,
    children: [{
      path: 'addpjProduct',
      name: 'addpjProduct',
      component: () => import('@/views/ProductAdmin/pjProduct/add.vue'),
      hidden: true,
      meta: {
        title: '发布配件商品',
        // keepAlive:true,
        icon: 'iconfont icon-zanwushuju'
      }
    }]
  },


]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [

  { path: '*', redirect: '/404', hidden: true }

]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
